Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

kleur

Package Overview
Dependencies
Maintainers
1
Versions
21
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

kleur

The fastest Node.js library for formatting terminal text with ANSI colors~!

  • 1.0.2
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created

What is kleur?

The kleur npm package is a library for formatting terminal text with ANSI colors. It provides a simple and chainable API to style strings that are output to the console with various colors, backgrounds, and text styles.

What are kleur's main functionalities?

Coloring text

This feature allows you to apply text color to your console output. The example shows how to color the text green.

const kleur = require('kleur');
console.log(kleur.green('Hello world!'));

Chaining styles

Kleur supports chaining multiple styles together. In this example, the text 'Error!' is styled to be red, bold, and underlined.

const kleur = require('kleur');
console.log(kleur.red().bold().underline('Error!'));

Background colors

You can also set background colors for your text. Here, the text 'Info' has a blue background with white foreground color.

const kleur = require('kleur');
console.log(kleur.bgBlue().white('Info'));

Conditional styling

Kleur allows conditional styling, where you can enable or disable colors based on certain conditions. In this example, the red color is applied only if the environment is not production.

const kleur = require('kleur');
const enabled = process.env.NODE_ENV !== 'production';
console.log(kleur.enabled(enabled).red('Only styled if not in production'));

Other packages similar to kleur

Keywords

FAQs

Package last updated on 17 Jul 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc